<script setup lang="ts">
import { ref } from "vue";
import { formRules } from "./utils/rule";
import { FormProps } from "./utils/types";

const props = withDefaults(defineProps<FormProps>(), {
  formInline: () => ({
    pid: "",
    realName: "",
    accountName: "",
    accountDesc: "",
    tenantName: "",
    accountType: 0,
    editStatus: false
  })
});

const ruleFormRef = ref();
const newFormInline = ref(props.formInline);

function getRef() {
  return ruleFormRef.value;
}

defineExpose({ getRef });
</script>

<template>
  <el-form
    ref="ruleFormRef"
    :model="newFormInline"
    :rules="formRules"
    label-width="82px"
  >
    <el-form-item label="账户名称" prop="realName">
      <el-input
        v-model="newFormInline.realName"
        clearable
        placeholder="请输入账户名称"
      />
    </el-form-item>

    <el-form-item label="登录名称" prop="accountName">
      <el-input
        v-model="newFormInline.accountName"
        clearable
        placeholder="请输入登录名称"
        :disabled="newFormInline.editStatus"
      />
    </el-form-item>
    <el-form-item label="租户名称" prop="tenantName">
      <el-input
        v-model="newFormInline.tenantName"
        clearable
        placeholder="请输入租户名称"
      />
    </el-form-item>
    <el-form-item label="账户类型：" prop="accountType">
      <el-select
        v-model="newFormInline.accountType"
        placeholder="请选择账户类型"
      >
        <el-option label="管理员" :value="1" />
        <el-option label="普通账户" :value="0" />
      </el-select>
    </el-form-item>

    <el-form-item label="备注">
      <el-input
        v-model="newFormInline.accountDesc"
        placeholder="请输入备注信息"
        type="textarea"
      />
    </el-form-item>
  </el-form>
</template>
